
ALTER PROCEDURE [dbo].[sp_SelectPhieuDatAll]
@TONGPHIEU INT OUTPUT
AS
BEGIN
BEGIN TRAN
	SET TRAN ISOLATION LEVEL SERIALIZABLE
	SELECT @TONGPHIEU = (SELECT COUNT(*) FROM PHIEUDAT)
	
	WAITFOR DELAY '00:00:15'

	SELECT  Ma_PD,NV_Dat,Ten_KH,DiaChi,DienThoai,NgayDat,ThanhTien,TinhTrang,GhiChu FROM PhieuDat
	
COMMIT TRAN
END
GO
--select * from phieudat
--Exec sp_SelectPhieuDatAll
--select * from phieudat





--////////////////////////////////////////////DAT HANG/////////////////////////////////////////
ALTER PROCEDURE [dbo].[sp_InsertPhieuDat]
	@Ma_PD nchar(3),
	@NV_Dat nchar(3),
	@Ten_KH nvarchar(50),
	@DiaChi nvarchar(100),
	@DienThoai nvarchar(15),
	@NgayDat datetime,
	@ThanhTien  float,
	@TinhTrang  int,
	@GhiChu nvarchar(100)
AS
BEGIN
BEGIN TRAN
	INSERT INTO PhieuDat  VALUES(@Ma_PD,@NV_Dat,@Ten_KH,@DiaChi,@DienThoai,@NgayDat,@ThanhTien,@TinhTrang,@GhiChu)
COMMIT TRAN
END
GO
--EXEC sp_InsertPhieuDat '313', '001', 'a', 'a', 'a', '9/9/2013', 1, 1, 'a'
